<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script src="../js/vue.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<div id="app">
			{{totalprice}}
		</div>
		<script type="text/javascript">
			var app = new Vue({
				el:'#app',
				data:{
					books:[
						{id:110, name:'书1', price:119},
						{id:111, name:'书2', price:105},
						{id:112, name:'书3', price:98},
						{id:113, name:'书4', price:87}
					]
				},
				computed:{
					totalprice: function(){
						let result = 0
						// for (let i in this.books) {
						// 	result += this.books[i].price
						// }
						for (let book of this.books) {
							result += book.price
						}
						return result;
					}
				}
			})
		</script>
	</body>
</html>
